#!/bin/bash
WORK_DIR=`pwd`
CM_TIME=`date +%Y-%m-%d:%H:%M:%S`
CM_MESSAGE=""
args=$@
remote='origin'
branch='main'
CM_USER="xumeng"

if [ -n "$1" ];then
    branch=$1
fi
if [ -n "$2" ];then
    CM_MESSAGE=$2
fi

if [ ! -n "$branch" ];then
    echo "分支不能为空"
    exit 0;
fi


echo "WORK_DIR="${WORK_DIR}
echo "remote="${remote}
echo "branch="${branch}
echo "CM_TIME="${CM_TIME}
echo "CM_MESSAGE="${CM_MESSAGE}

git config --global user.name "xumeng"
git config --global user.email "495150620@qq.com"
git config core.fileMode false
git config core.ignorecase false

push(){
    cd $WORK_DIR
    git add  "."
    git status
    sleep 1
    git commit -m "[$branch]-$CM_TIME $CM_USER ${CM_MESSAGE}"
    git push $remote $branch
}

push
